﻿using System.Windows.Forms;
using ApplicationGenerator.Lists.BusinessLogic;

namespace GUserInterface.WinForms.Lists
{
    public partial class ColumnsConfigurationControl : BaseWizardPage
    {
        private BaseWizardPage _displayControl;

        public ColumnsConfigurationControl()
        {
            InitializeComponent();
        }

        public override void ShowPage(Panel wizardSheet, ListConfiguration listConfiguration)
        {
            if (!wizardSheet.Controls.Contains(this))
            {
                this.Dock = DockStyle.Fill;
                wizardSheet.Controls.Add(this);
                
                if (listConfiguration.ConfigType == ListConfigurationType.Tree)
                {
                    _displayControl = new TreeConfigurationForm();
                }
                else
                {
                    _displayControl = new HQLConfigurationControl();
                }

                _displayControl.Dock = DockStyle.Fill;
                this.Controls.Add(_displayControl);
            }

            _displayControl.ShowPage(wizardSheet, listConfiguration);
            _displayControl.ShowVisible(true);
        }

        public override void SaveConfiguration(ListConfiguration listConfiguration)
        {
            _displayControl.SaveConfiguration(listConfiguration);
        }

        public override bool ValidateConfiguration()
        {
            return _displayControl.ValidateConfiguration();
        }
    }
}
